import time
from pywinauto.application import Application

# 启动应⽤程序
Application(backend="uia").start("notepad.exe")
time.sleep(3)
app = Application(backend="uia").connect(title_re=".*Notepad")
# 获取窗⼝
notepad = app.window(title_re=".*Notepad")
# 操作控件
# 输⼊⽂本
notepad.Document.type_keys("Hello, Pywinauto!")
# 关闭应⽤程序
notepad.close()
